'''
Copyright: 
Descripttion: 
version: 
Author: chengx
Date: 2021-05-22 19:31:46
LastEditors: chengx
LastEditTime: 2021-05-30 21:07:28
'''
import sys
from typing import Sequence
from PyQt5 import QtWidgets,QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

class UI_BandSelection(QWidget):

    def __init__(self,parent=None):
        super(UI_BandSelection, self).__init__(parent)
        self.setWindowIcon(QIcon('logo.ico'))
        self.setWindowFlags(Qt.FramelessWindowHint) #不显示菜单栏
        QtWidgets.QShortcut(QtGui.QKeySequence('Esc', ), self, self.close)  # esc关闭窗口

        HOR=QHBoxLayout()
        HOR.addWidget(self.toolmenu_groupBox(),1)
        HOR.addWidget(self.labelPic(),8)

        VER = QVBoxLayout()
        VER.addLayout(HOR,3)
        VER.addWidget(self.output_groupBox(),1)
        self.setLayout(VER)
        
        listwidgetStyle = "UI_BandSelection{background:#708fb3}\
                            QLabel{border:0px;background-color:transparent;}\
                            QPushButton{background-color:rgba(112,112,99,100);border-radius:20px;\
                                font:bold 24px;color:white;min-width:100px;min-height:100px;}\
                                QPushButton:hover{background-color:rgba(171,121,127,100);color:rgba(255,0,0,200);}\
                                QComboBox{border:none;background:#a8cab8;color:white;font-size:25px;min-width:100;border-radius:5px;}\
                                QGroupBox{background-color:#24231e;border-radius:15px;border:0px;}\
                                QTextEdit{font-size:20px;background-color:transparent;border:0px;color:white;}"
        self.setStyleSheet(listwidgetStyle)
        self.setFixedSize(1000,800)

    def labelPic(self):
        groupBox = QGroupBox()
        self.lab1=QLabel()
        self.lab2=QLabel()
        HOR = QHBoxLayout()
        HOR.addWidget(self.lab1,1)
        HOR.addWidget(self.lab2,1)
        groupBox.setLayout(HOR)
        return groupBox

    def toolmenu_groupBox(self): # 工具栏
        groupBox = QGroupBox()
        VER = QVBoxLayout()
        self.loadBtn = QPushButton('加载图片')
        self.runBtn = QPushButton('分类')
        self.taskName = QComboBox()
        a = ['全波段','ICA','ABC']
        self.taskName.addItems(a)

        VER.addWidget(self.loadBtn)
        VER.addWidget(self.taskName)
        VER.addWidget(self.runBtn)

        groupBox.setLayout(VER)
        return groupBox

    def output_groupBox(self):#输出栏
        groupBox = QGroupBox()
        HOR = QHBoxLayout()
        self.output = QTextEdit()
        self.output.moveCursor(QTextCursor.End)
        self.output.setText('请加载光谱图')
        HOR.addWidget(self.output)
        groupBox.setLayout(HOR)
        return groupBox

    def show_massage(self,msg):#输出框输出信息
        self.output.append(msg)
    
    def show_grayImage(self):
        img = QImage()
        img.load('./gray.jpg')
        self.lab1.setPixmap(QPixmap.fromImage(img))
        self.lab1.setScaledContents(True) 
        self.lab1.show()
        self.output.append('高光谱图像加载完成')

    def show_rgbImage(self):
        img = QImage()
        img.load('./rgb.jpg')
        self.lab2.setPixmap(QPixmap.fromImage(img))
        self.lab2.setScaledContents(True) 
        self.lab2.show()
        self.output.append('end')

if __name__ == '__main__':
  app = QApplication(sys.argv)
  demo =UI_BandSelection()
  demo.show()
  sys.exit(app.exec_())